export default class Calendar{
  static singleton:Calendar;

  date:Date;
  private constructor(){
    console.log('初始化日历对象');
    this.date = new Date();
  }

  setDate(year:number, month:number, date:number):void{
    this.date.setFullYear(year);
    this.date.setMonth(month-1);
    this.date.setDate(date);
  }

  getDate():string{
    let date:Date = this.date;
    return `${date.getFullYear()}/${date.getMonth()+1}/${date.getDate()}`;
  }

  static getInstance():Calendar{
    if(!this.singleton){
      this.singleton = new Calendar();
    }
    return this.singleton;
  }
}